<template>
  <div>
    <div id="app" class="wrapper wrapper-content">
      <div class="row">
        <div>
          <div class="panel panel-primary">
            <div class="panel-body" style="padding: 0px 120px; box-sizing: border-box;">
                <el-form size="small" :model="inputForm" ref="inputForm" v-loading="loading">
                    <div  style="text-align:center">
                        <h3 style="font-weight: bold;color: black;font-size:24px">薪资发放申请单</h3>
                    </div>
                    <table style="margin:0 auto;width:80%;margin-top:20px;border-collapse: collapse;margin-bottom:20px">
                        <tr style="line-height: 3.5;">
                            <td colspan="4"
                                style="font-weight: bold;text-align: left;padding-left: 32px;position: relative;font-size: 14px">
                                <img src="../../../../../assets/imgs/processManagement/work.png" alt=""
                                      style="position: absolute;width: 20px;height: 20px;left: 0px;top: 14px;margin-left: 8px">
                                基本信息
                            </td>
                        </tr>
                        <tr class="iconHidden">
                            <td class="width-15">申请人</td>
                            <td class="width-30" >
                                <el-form-item  prop="applyuser.id">
                                      <user-select :limit='1' :value="inputForm.applyuser.id" @getValue='(value) => {inputForm.applyuser.id=value}' disabled></user-select>
                                </el-form-item> 
                            </td>
                            <td class="width-15" >所属公司</td>
                            <td class="width-30"  >
                                <el-form-item  prop="company.id" >
                                <SelectTree
                                            ref="company"
                                            :props="{
                                                value: 'id',             // ID字段名
                                                label: 'name',         // 显示名称
                                                children: 'children'    // 子级字段名
                                              }"
                                            disabled
                                            url="/sys/office/treeData?type=2"
                                            :value="inputForm.company.id"
                                            :clearable="true"
                                            :accordion="true"
                                            @getValue="(value) => {inputForm.company.id=value}"/>
                                </el-form-item>
                            </td>
                        </tr>
                        <tr  class="iconHidden">
                            <td class="width-15">申请时间</td>
                            <td class="width-30">
                                <el-form-item prop="applydate" >
                                      <el-date-picker
                                            v-model="inputForm.applydate"
                                            type="datetime"
                                            disabled
                                            style="width: 100%;"
                                            value-format="yyyy-MM-dd HH:mm:ss"
                                            :clearable="false"
                                            placeholder="请选择">
                                          </el-date-picker>
                                </el-form-item>
                            </td>
                            <td class="width-15">所属部门</td>
                            <td class="width-30">
                                <el-form-item  prop="depart.id">
                                <SelectTree
                                            ref="depart"
                                            :props="{
                                                value: 'id',             // ID字段名
                                                label: 'name',         // 显示名称
                                                children: 'children'    // 子级字段名
                                              }"
                                            disabled
                                            url="/sys/office/treeData?type=2"
                                            :value="inputForm.depart.id"
                                            :clearable="true"
                                            :accordion="true"
                                            @getValue="(value) => {inputForm.depart.id=value}"/>
                                </el-form-item>   
                            </td>
                        </tr> 
                        <tr class="iconHidden" >
                            <td class="width-15"><span style="color: red">*&nbsp;</span>工资年月</td>
                            <td class="width-30">
                                <el-form-item  prop="salarydate" :rules="[{required: true, message:'工资年月不能为空', trigger:'blur'}]">
                                  <el-date-picker
                                    v-model="inputForm.salarydate"
                                    type="month"
                                    @change="monthUserInfo"
                                    style="width: 100%;"
                                    value-format="yyyy-MM"
                                    :clearable="false"
                                    placeholder="请选择">
                                  </el-date-picker>
                                </el-form-item>
                            </td>
                            <td class="width-15"></td>
                            <td class="width-30"></td>     
                        </tr> 
                        <tr style="height: 80px;line-height: 80px">
                            <td class="width-15 active" style="line-height: 80px">备注信息
                            </td>
                            <td colspan="4" style="padding:0 10px">
                              <el-form-item  prop="remarks">
                                  <el-input type="text" v-model="inputForm.remarks"></el-input>
                                </el-form-item>
                            </td>
                        </tr>                        
                        <tr style="line-height: 3.5;">
                            <td colspan="4"
                                style="font-weight: bold;text-align: left;padding-left: 32px;position: relative;font-size: 14px">
                                <img src="../../../../../assets/imgs/processManagement/basic.png" alt=""
                                      style="position: absolute;width: 20px;height: 20px;left: 0px;top: 14px;margin-left: 8px">
                                工资发放附表
                                <span style="margin-left:70px;" v-if="haveAuthority">
                                  <span style="color:red">账户余额:</span>
                                  <span v-if="accountBalancesShow" style="padding:0 5px">****</span>
                                  <span v-if="!accountBalancesShow" style="padding:0 5px;font-weight:400;">{{this.accountBalances}}</span>
                                  <i class="el-icon-view" @click="showOrHidden" style="color:#1296DB"></i>
                                </span>
                            </td>
                        </tr>
                        <tr  v-if="!formReadOnly || (this.$route.query.code &&this.$route.query.attends)">
                             <td colspan="4" class="addDelImg">                             
                                <i v-if="this.showButton && this.inputForm.salarydate" id="add" @click="addVisibles" class="el-icon-circle-plus" ></i>
                                <i v-if="this.showButton" id="sub" class="el-icon-remove" @click="delAll" ></i>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="4" class="elTable">
                                <div style="width:100%">
                                    <!-- <el-button size="small" @click="addSalaryEntryRow" type="primary">新增</el-button> -->
                                    <!-- show-summary -->
                                    <el-table
                                      :data="inputForm.salaryEntryList.filter(function(item){ return item.delFlag !== '1'})" 
                                      size="small" row-key="id" style="border-collapse:collapse;"                                  
                                      :cell-style="cellStyle_attached" ref="mytables"
                                      :row-class-name="tableRowClassName" 
                                      :header-cell-class-name="cellHeadStyle_attached"                                                      
                                      :tree-props="{ children: 'children', hasChildren: 'hasChildren'}"                  
                                      >
                                      <el-table-column type="selection" width="50" align="center"></el-table-column>
                                      <el-table-column prop="username.name"  header-align="center"  show-overflow-tooltip label="姓名" width="80">
                                        <template slot-scope="scope">
                                            <span @click="salaryInfos(scope.row.salaryid)" style="color:#1890ff;cursor:pointer">{{scope.row.username.name}}</span>
                                        </template>                                 
                                      </el-table-column>
                                      <el-table-column prop="phone"  header-align="center"  show-overflow-tooltip  label="电话" ></el-table-column>
                                      <el-table-column  prop="depart.name"  header-align="center"  show-overflow-tooltip  label="部门" ></el-table-column>
                                      <el-table-column  prop="bankname"  header-align="center"  show-overflow-tooltip  label="开户行" ></el-table-column>
                                      <el-table-column  prop="bankarea"  header-align="center"  show-overflow-tooltip  label="开户地" ></el-table-column>
                                      <el-table-column  prop="bankaccount"  header-align="center"  show-overflow-tooltip  label="卡号" ></el-table-column>
                                      <el-table-column  prop="salaryamount"  header-align="center"  show-overflow-tooltip  label="实发工资"></el-table-column>
                                      <!-- <el-table-column  prop="salaryid"  header-align="center"  align="center"  show-overflow-tooltip  label="工资id" >
                                        <template slot="header">
                                            <span style="color: red">*&nbsp;</span>
                                            <span>工资id</span>                                    
                                        </template>
                                        <template slot-scope="scope">
                                          <el-input v-model="scope.row.salaryid"  :disabled="formReadOnly"></el-input>
                                        </template>
                                      </el-table-column>   -->
                                      <el-table-column  prop="remarks"  header-align="center"  align="center"  show-overflow-tooltip  label="说明" >
                                        <template slot-scope="scope">
                                          <el-input v-model="scope.row.remarks"  :disabled="formReadOnly"></el-input>
                                        </template>
                                      </el-table-column>               
                                    </el-table>
                                </div>
                            </td>
                        </tr>
                    </table>
                </el-form>                
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- <SalaryEntryForm ref="salaryEntryForm" @addRow="saveSalaryEntryRow(arguments)"></SalaryEntryForm> -->
    <el-dialog title="工资信息"  :close-on-click-modal="false"  v-dialogDrag  :visible.sync="addVisible">
        <div style="display:flex">
          <div style="flex:1">
            <el-select v-model="officeId" placeholder="部门" size="small" @change="monthUserInfo">
              <el-option v-for="item in optionsOffice" :key="item.id" :label="item.name" :value="item.id" ></el-option>
            </el-select>
          </div>
          <el-button size="small" @click="officeIdReset">清空</el-button>
        </div>
        
      <el-table :cell-style="cellStyle" :header-cell-class-name="cellHeadStyle" @selection-change="handleSelectionChange"
        style="width:100%; border:1px solid #d6cfe2" :data="salaryTable" size="mini"  ref="salaryTables" class="table"
        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" row-key="id">
        <el-table-column type="selection" width="50" align="center"></el-table-column>
        <el-table-column prop="name" label="姓名" show-overflow-tooltip></el-table-column>
        <el-table-column prop="phone" label="电话" show-overflow-tooltip></el-table-column>
        <el-table-column prop="office.name" label="部门" show-overflow-tooltip></el-table-column>
        <el-table-column prop="bankofdeposit" label="开户行" show-overflow-tooltip></el-table-column>
        <el-table-column prop="bankarea" label="开户地" show-overflow-tooltip></el-table-column>
        <el-table-column prop="bankaccount" label="卡号" show-overflow-tooltip min-width="120"></el-table-column>
        <el-table-column prop="netpayroll" label="实发工资" show-overflow-tooltip min-width="100"></el-table-column>  
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="addVisible = false">关闭</el-button>
        <el-button size="small" type="primary" @click="confrim">确定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="薪资详情"  :close-on-click-modal="false"  v-dialogDrag  :visible.sync="salaryInfo" width="60%">
      <el-table  :data="salaryContent" v-loading="salaryContentLoading" height="calc(100% - 80px)"
        style="border: 1px solid #d6cfe2" row-key="id" size="small" :cell-style="cellStyle"
        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" class="table"
        :header-cell-class-name="cellHeadStyle">
        <el-table-column prop="salyear" label="日期" align="center" fixed="left" show-overflow-tooltip></el-table-column>
        <el-table-column  prop="user.name"  label="姓名"  fixed="left" align="center"  show-overflow-tooltip></el-table-column>
        <el-table-column label="基本信息">
          <el-table-column  prop="idnumber.name"  label="部门" align="center"  show-overflow-tooltip></el-table-column>
          <el-table-column  prop="job" label="岗位" align="center"  show-overflow-tooltip></el-table-column>
        </el-table-column>
        <el-table-column label="考勤 (天)">
          <el-table-column prop="shouldattendanceday" label="应出勤" align="center"  show-overflow-tooltip></el-table-column>
          <el-table-column  prop="traveldays"  label="出差" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column  prop="leavedays"  label="请假" align="center"  show-overflow-tooltip></el-table-column>
          <el-table-column prop="realityattendanceday" label="实际出勤" align="center" show-overflow-tooltip></el-table-column>
        </el-table-column>
        <el-table-column label="固定工资 (元)">
          <el-table-column  prop="basepay" align="center"  label="基本工资"  show-overflow-tooltip></el-table-column>
          <el-table-column   prop="postwage" align="center"  label="岗位工资"  show-overflow-tooltip></el-table-column>
          <el-table-column  prop="meritpay" align="center" label="绩效工资"  show-overflow-tooltip></el-table-column>
          <el-table-column  prop="combinedbasic" label="固定合计" align="center" show-overflow-tooltip></el-table-column>
        </el-table-column>
        <el-table-column label="福利待遇 (元)">
          <el-table-column prop="senioritypay" label="工龄工资" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column  prop="mealallowance"  label="餐费补助" align="center"  show-overflow-tooltip></el-table-column>
          <el-table-column  prop="trafficallowance"  label="交通补助" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column   prop="commission"  label="业务提成" align="center"  show-overflow-tooltip></el-table-column>
          <el-table-column  prop="travelallowance"  label="出差补助" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column  prop="attendancebonus" label="全勤奖" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column  prop="overtime" align="center"  label="加班费"  show-overflow-tooltip></el-table-column>
          <el-table-column  prop="communicatesubsidy"  label="通信补助" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column   prop="othersupport"  label="其他补助" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column prop="totalwelfarebenefits"  label="福利合计" align="center" show-overflow-tooltip></el-table-column>
        </el-table-column>
        <el-table-column prop="shouldsalary"  label="应发工资(元)"  width="100px" align="center"  show-overflow-tooltip></el-table-column>
        <el-table-column label="扣减项目 (元)">
          <el-table-column align="center"   prop="housingprovidentfund"  label="公积金"  show-overflow-tooltip ></el-table-column>
          <el-table-column align="center" prop="party" label="党费" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" prop="basicoldagepension" label="基本养老" show-overflow-tooltip></el-table-column>
          <el-table-column  prop="basicmedicalcare"  label="基本医疗" align="center"  show-overflow-tooltip></el-table-column>
          <el-table-column prop="unemploymentinsurance"  label="失业保险" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column  prop="individualincometax"  label="所得税" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column  prop="workInjury" label="工伤" align="center"show-overflow-tooltip></el-table-column>
          <el-table-column prop="lately" label="迟到" align="center"show-overflow-tooltip></el-table-column>
          <el-table-column prop="leaveearly"  label="早退" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column prop="absenteeism" label="旷工" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column prop="otherdeductions" label="其他扣款" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column prop="deductionscombined" label="扣减合计" align="center" show-overflow-tooltip></el-table-column>
        </el-table-column>
        <el-table-column label="企业保险 (元)">
          <el-table-column prop="providentFund" label="企业公积金" width="110px" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column prop="pension" label="企业养老" width="110px" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column prop="medical" label="企业医疗" align="center" width="110px" show-overflow-tooltip></el-table-column>
          <el-table-column prop="unemployment" label="企业失业" align="center" width="110px" show-overflow-tooltip></el-table-column>
          <el-table-column prop="businessInjury" label="企业工伤" align="center" width="110px" show-overflow-tooltip></el-table-column>
          <el-table-column prop="otherFee" label="企业其他费用" width="110px" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column prop="totalFees" label="企业费用合计" width="110px" align="center" show-overflow-tooltip></el-table-column>
        </el-table-column>
        <el-table-column prop="netpayroll" label="实发工资(元)" width="100px" align="center" show-overflow-tooltip></el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog title="账户余额查询" :visible.sync="accountBalancesDialog"  width="20%" :before-close="closePwd">
        <el-form :model="accountBalancesForm" size="small"   label-width="80px" ref="accountBalancesForms"  v-loading="accountBalancesLoading">
            <el-row  :gutter="15">
                <el-col :span="18">
                    <el-form-item label="密码" prop="pwd"  :rules="[ {required: true, message:'请输入账户密码', trigger:'blur'} ]">
                        <el-input v-model="accountBalancesForm.pwd" placeholder="请输出该账号密码" type="password"></el-input>
                    </el-form-item>
                </el-col>                
            </el-row>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button size="small" type="primary" @click="closePwd" plain>关闭</el-button>
            <el-button size="small" type="primary" @click="confirmPwd"  plain>确定</el-button>
        </span>
    </el-dialog>
  </div>
</template>

<script>
  import SalaryEntryForm from './SalaryEntryForm'
  import UserSelect from '@/components/userSelect'
  import SelectTree from '@/components/treeSelect/treeSelect.vue'
  import tableStyles from '../../../../../utils/mixins.js'
  export default {
    mixins: [tableStyles],
    data () {
      return {
        title: '',
        method: '',
        loading: false,
        inputForm: {
          id: '',
          salaryEntryList: [],
          applyuser: {
            id: ''
          },
          company: {
            id: ''
          },
          applydate: '',
          depart: {
            id: ''
          },
          salarydate: '',
          remarks: ''
        },
        officeId:"",//部门id
        optionsOffice:[],//部门数组
        showButton:true,//按钮显示与否
        addVisible:false,//薪资添加弹出页面
        salaryTable:[],//选择弹出框
        checkSelection:[],//选中数据
        salaryInfo:false,    //详情弹出框
        salaryContent:[],
        salaryContentLoading:'',

        accountBalances:'',
        accountBalancesShow:true,//账户余额
        accountBalancesDialog:false,
        accountBalancesForm:{
          pwd:'',
        },
        accountBalancesLoading:'',
        haveAuthority:false,//账户余额显示与否,
      }
    },
    props: {
      businessId: {
        type: String,
        default: ''
      },
      formReadOnly: {
        type: Boolean,
        default: false
      }
    },
    components: {
      UserSelect,
      SelectTree,
      SalaryEntryForm
    },
    watch: {
      'businessId': {
        handler (newVal) {
          if(this.$store.state.user.id!=''){
            var users=this.$store.state.user
          }else{
            var users=JSON.parse(sessionStorage.getItem("userInfo"));
          } 
          if (this.businessId) {
            this.init(this.businessId);
            this.getHaveAuthority();//获取是否具有查看账户余额权限
          } else {
            this.$nextTick(() => {
              this.$refs.inputForm.resetFields();
              this.inputForm.applyuser.id=users.id;
              this.inputForm.company.id=users.company.id;
              this.inputForm.depart.id=users.office.id;
              this.inputForm.applydate=this.getNowTime();
            })
          }
        },
        immediate: true,
        deep: false
      }
    },
    created(){
      window.addEventListener("beforeunload",()=>{
        sessionStorage.setItem("userInfo",JSON.stringify(this.$store.state.user))
      })
    },
    methods: {
      init (id) {
        if (id) {
          this.inputForm.salaryEntryList = []
          this.loading = true
          this.inputForm.id = id
          this.$nextTick(() => {
            this.$refs.inputForm.resetFields()
            this.$http({
              url: `/dlyrl/oa/paysalary/paySalary/queryById?id=${this.inputForm.id}`,
              method: 'get'
            }).then(({data}) => {
              this.inputForm = this.recover(this.inputForm, data.paySalary)
              this.loading = false;
              if(this.$route.query.readOnly=='true'){
                this.showButton=false;
              } 
            })
          })
        }
      },
      addVisibles(){
        this.addVisible=true;
        this.getOffices();
      },
      officeOk(){
        this.monthUserInfo();
      },
      officeIdReset(){
        this.officeId="";
        this.monthUserInfo();
      },
      // 获取部门
      getOffices(){
        this.$http({
          url: `/sys/web/userinfo/findDepartemnt`,
          method: 'get',
          params:{
            id:this.$store.state.user.companyId,
          }
        }).then(({data}) => {
          if (data && data.success) {               
            console.log("部门",data)
            this.optionsOffice=data.list;
          }
        })  
      },
      // saveSalaryEntryRow (child) {
      //   if (child[0] === '') {
      //     this.inputForm.salaryEntryList.push(child[1])
      //   } else {
      //     this.inputForm.salaryEntryList.forEach((item, index) => {
      //       if (item === child[0]) {
      //         this.inputForm.salaryEntryList.splice(index, 1, child[1])
      //       }
      //     })
      //   }
      // },         
      // addSalaryEntryRow (child) {
      //   this.$refs.salaryEntryForm.init('add')
      // },
      // viewSalaryEntryRow (child) {
      //   this.$refs.salaryEntryForm.init('view', child)
      // },
      // editSalaryEntryRow (child) {
      //   this.$refs.salaryEntryForm.init('edit', child)
      // },
      // delSalaryEntryRow (child) {
      //   this.inputForm.salaryEntryList.forEach((item, index) => {
      //     if (item === child && item.id === '') {
      //       this.inputForm.salaryEntryList.splice(index, 1)
      //     } else if (item === child) {
      //       item.delFlag = '1'
      //       this.inputForm.salaryEntryList.splice(index, 1, item)
      //     }
      //   })
      // },
      //个人薪资信息
      monthUserInfo(){
        this.inputForm.salaryEntryList=[];
        this.salaryTable=[];
        this.$http({
          url: `/dlyrl/oa/paysalary/paySalary/getUserSalary`,
          method: 'get',
          params:{
            companyId:this.$store.state.user.companyId,
            userid:this.$store.state.user.id,
            officeId:this.officeId,
            // companyId:'484tf521yg854hg6asyg',
            yearMon:this.inputForm.salarydate
          }
        }).then(({data}) => {
          if (data && data.success) {               
            // console.log(data,'d')
            this.salaryTable=data.users;
          }
        })       
      },  
      //选中的薪资信息
      handleSelectionChange(val) {
          this.checkSelection= val;
          console.log(val)
      },
      //确认
      confrim(){
        this.addVisible=false;
        this.inputForm.salaryEntryList=[];
        for(let i=0;i<this.checkSelection.length;i++){
          let a={
            username:{
              name:this.checkSelection[i].name,
              id:this.checkSelection[i].id,
            },
            phone:this.checkSelection[i].phone,
            depart:{
              name:this.checkSelection[i].office.name,
              id:this.checkSelection[i].office.id,
            },
            bankname:this.checkSelection[i].bankofdeposit,
            bankarea:this.checkSelection[i].bankarea,
            bankaccount:this.checkSelection[i].bankaccount,
            salaryamount: this.checkSelection[i].netpayroll,
            salaryid: this.checkSelection[i].salaryid
          }
          this.inputForm.salaryEntryList.push(a)
        }
      },
      //薪资详情
      salaryInfos(id){
        this.salaryInfo=true;
        this.salaryContentLoading=true;
        this.salaryContent=[];
        this.$http({
          url: `/sys/usersalary/userSalary/queryById`,
          method: 'get',
          params:{
            id:id
          }
        }).then(({data}) => {
          this.salaryContentLoading=false;
          if (data && data.success) {               
            // console.log(data,'d')
            this.salaryContent.push(data.userSalary);
          }
        }) 
      },
      // 表单提交
      saveForm (callback) {
        // console.log(this.inputForm,'22')
        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.loading = true
            this.$http({
              url: `/dlyrl/oa/paysalary/paySalary/save`,
              method: 'post',
              data: this.inputForm
            }).then(({data}) => {
              this.loading = false;
              if (data && data.success) {               
                callback(data.businessTable, data.businessId);
                this.$refs.inputForm.resetFields();
                this.inputForm.applyuser.id=this.$store.state.user.id;
                this.inputForm.company.id=this.$store.state.user.company.id;
                this.inputForm.depart.id=this.$store.state.user.office.id;
                this.inputForm.applydate=this.getNowTime();
              }
            })
          }
        })
      },
      //添加行序号
      tableRowClassName({row, rowIndex}) {
        row.index = rowIndex;
      },
      //删除
      delAll() {
          for (var i = this.$refs.mytables.selection.length - 1; i >= 0; i--) {
            this.inputForm.salaryEntryList.splice(this.$refs.mytables.selection[i].index, 1)
            this.$refs.salaryTables.toggleRowSelection(this.$refs.mytables.selection[i],false);
          }
          this.$refs.mytables.clearSelection();
      },
      //获取是否具有查看账户余额权限
      getHaveAuthority(){
        if(this.$store.state.user.id!=''){
          var users=this.$store.state.user
        }else{
          var users=JSON.parse(sessionStorage.getItem("userInfo"));
        } 
        this.$http({
          url: '/accountBalance/getUserAuthority',
          method: 'get',
          params:{
              uid:users.id,                  
          }
          }).then(({data}) => {             
            if(data&&data.success&&data.authority==1){                  
               this.haveAuthority=true;
            }             
        })

      },
      //余额与****切换
      showOrHidden(){
        this.accountBalancesShow=!this.accountBalancesShow;
        if(!this.accountBalancesShow){
          this.accountBalances='';
          this.accountBalancesDialog=true;
        }
      },
      //查询余额关闭
      closePwd(){
        this.accountBalancesShow=true;
        this.accountBalancesDialog=false;
        this.$refs.accountBalancesForms.resetFields();
      },
       //查询余额确认
      confirmPwd(){
          if(this.$store.state.user.id!=''){
            var users=this.$store.state.user
          }else{
            var users=JSON.parse(sessionStorage.getItem("userInfo"));
          }   
          this.$refs['accountBalancesForms'].validate((valid) => {
            if (valid) {
                this.accountBalancesLoading=true;
                this.$http({
                url: '/accountBalance/getBalance',
                method: 'get',
                params:{
                    uid:users.id,
                    company:users.company.id,
                    pwd:this.accountBalancesForm.pwd                    
                }
                }).then(({data}) => {             
                  this.accountBalancesLoading=false;
                  this.accountBalancesDialog=false;
                  this.$refs.accountBalancesForms.resetFields();
                  if(data&&data.success){                  
                      this.$message.success(data.msg);
                      this.accountBalances=data.balance;
                  }else{
                    this.accountBalancesShow=true;
                  }              
                })
            }
          })  
      },
    }
  }
</script>